cmake_minimum_required(VERSION 2.6)

set(LIBARARY_NAME "FastRT" CACHE STRING "The Fastreid-tensorrt library name")

set(LIBARARY_VERSION_MAJOR "0")
set(LIBARARY_VERSION_MINOR "0")
set(LIBARARY_VERSION_SINOR "3")
set(LIBARARY_SOVERSION "0")
set(LIBARARY_VERSION "${LIBARARY_VERSION_MAJOR}.${LIBARARY_VERSION_MINOR}.${LIBARARY_VERSION_SINOR}")
project(${LIBARARY_NAME}${LIBARARY_VERSION})

add_definitions(-std=c++11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/")
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_LINK_EXECUTABLE ${CMAKE_CXX_LINK_EXECUTABLE})

# option for shared or static
set(TARGET "SHARED" CACHE STRING "SHARED or STATIC" FORCE)

if("${TARGET}" STREQUAL "SHARED")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
message("Build Engine as shared library")
else()
  message("Build Engine as static library")
endif()

option(CUDA_USE_STATIC_CUDA_RUNTIME "Use Static CUDA"     OFF)
option(BUILD_FASTRT_ENGINE     "Build FastRT Engine"       ON)
option(BUILD_DEMO              "Build DEMO"               OFF)
option(BUILD_FP16              "Build Engine as FP16"     OFF)

if(BUILD_FP16)
  add_definitions(-DBUILD_FP16)
  message("Build Engine as FP16")
else()
  message("Build Engine as FP32")
endif()

set(SOLUTION_DIR ${CMAKE_CURRENT_SOURCE_DIR})
message("CMAKE_CURRENT_SOURCE_DIR: " ${SOLUTION_DIR})

if(BUILD_FASTRT_ENGINE)
  add_subdirectory(fastrt)
  message(STATUS "BUILD_FASTREID_ENGINE: ON")
else()
  message(STATUS "BUILD_FASTREID_ENGINE: OFF")
endif()

if(BUILD_DEMO)
  add_subdirectory(demo)
  message(STATUS "BUILD_DEMO: ON")
else()
  message(STATUS "BUILD_DEMO: OFF")
endif()
